import request from "@/request";
import ResultEnum from "@/config/ResultEnum";

export interface FormValue {
  tagLabel: string;
  groupKey: string;
  status: string | undefined;
  icon: any;
}

export const statusOptions = [
  {
    label: "正常",
    value: "Normal",
    color: "#2db7f5",
  },
  {
    label: "禁用",
    value: "Disable",
    color: "#87d068",
  },
];

export const getTagGroupKeys = () => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/tags/groups",
      method: "get",
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        let result = res.result;
        let arr = [] as any;
        for (let item of result) {
          arr.push({
            label: item.name,
            value: item.value,
          });
        }
        resolve(arr);
      }
    });
  });
};

export const submit = (data: any) => {
  return request({
    url: "/tags/add",
    method: "post",
    data,
  });
};
